<%@page import="java.util.Iterator"%>
<%@page import="java.util.List"%>
<%@page import="sdr.elementos.usuario"%>
<%@page import="org.hibernate.Session"%>
<%@page import="sdr.HibernateUtil"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>

    <%
%>
<%/*
  hsession = HibernateUtil.getSessionFactory().getCurrentSession();
        hsession.beginTransaction();

 List result = hsession.createCriteria(usuario.class).list();
        if (result.size() > 0) {
            out.println("<h2>Events in database:</h2>");
            out.println("<table border='1'>");
            out.println("<tr>");
            out.println("<th>Event title</th>");
            out.println("<th>Event date</th>");
            out.println("</tr>");
            Iterator it = result.iterator();
            while (it.hasNext()) {
                usuario event = (usuario) it.next();
                out.println("<tr>");
                out.println("<td>" + event.getNombres() + "</td>");
                //out.println("<td>" + dateFormatter.format(event.getDate()) + "</td>");
                out.println("</tr>");
            }
            out.println("</table>");
        }
 hsession.close();*/

if(request.getParameter("in")!=null){
    %><%=request.getParameter("usr")%><%
    %><%=request.getParameter("pass")%><%
usuario u=usuario.valid(request.getParameter("usr"), request.getParameter("pass"));

if(u!=null){
session.setAttribute("usuario", u);
response.sendRedirect("mapa.htm");
}

}
%>

    
    <body>
        <p> Bienvenido a su sistema de recomendaciones</p>
        <p><i>Ingrese su nombre de usuario y contrase&ntilde;a</i>
        <form name="form" method="POST">
        
        <table border="1">
            <thead>
                <tr>
                    <th>Correo</th>
                    <th><input type="text" name="usr" value="" /></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Pass</td>
                    <td><input type="password" name="pass" value="" /></td>
                </tr>
                <tr>
                    <td><a href="registro.htm">Registrar</a></td>
                    <td><input type="submit" value="Ingresar" name="in" /></td>
                </tr>
            </tbody>
        </table>
        </form>

        </p>
    </body>
</html>
